package com.java.demo;

import com.java.demo.mode.ArticleInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-07-19
 * Time: 12:40
 */

//@Controller("userinfo")

@Order(10)//多个相同的Bean（name），使用Order排序，数字越大优先级越高
@Component
public class User {
    public void sayHi() {
        System.out.println("user");
    }



    @Bean("article")//多个方法使用相同的name，第一个之后的都不会被放入容器，全部忽略
    public ArticleInfo gertArt() {
        //伪代码
        ArticleInfo articleInfo = new ArticleInfo();
        articleInfo.setAid(2);
        articleInfo.setTitle("今天周几");
        articleInfo.setContent("今天周一");
        articleInfo.setCreatetime(LocalDateTime.now());
        return articleInfo;
    }

    @Bean("article")
    public ArticleInfo gertArt1() {
        //伪代码
        ArticleInfo articleInfo = new ArticleInfo();
        articleInfo.setAid(3);
        articleInfo.setTitle("今天周几");
        articleInfo.setContent("今天周一");
        articleInfo.setCreatetime(LocalDateTime.now());
        return articleInfo;
    }

    @Bean("article")
    public ArticleInfo gertArt2() {
        //伪代码
        ArticleInfo articleInfo = new ArticleInfo();
        articleInfo.setAid(4);
        articleInfo.setTitle("今天周几");
        articleInfo.setContent("今天周一");
        articleInfo.setCreatetime(LocalDateTime.now());
        return articleInfo;
    }
}
